
package jweslley.ContestVolumes.VolumeCV;

import java.math.BigInteger;
import java.util.Scanner;

import jweslley.Problem;
import jweslley.Problem.Status;

/**
 * http://icpcres.ecs.baylor.edu/onlinejudge/external/105/10523.html
 *
 * @author  Jonhnny Weslley
 * @version 1.00, 18/10/2008
 */
@Problem(Status.Accepted)
public class VeryEasy {

	public static void main(String[] args) {
		StringBuilder out = new StringBuilder();
		Scanner in = new Scanner(System.in);
		int a, n;		
		while (in.hasNext()) {
			n = in.nextInt();
			a = in.nextInt();
			out
			.append(calcule(a, n))
			.append('\n');
		}
		System.out.print(out);
	}

	static Object calcule(int a, int n) {
		BigInteger sum = new BigInteger("0");
		for (int i = 1; i <= n; i++) {
			sum = sum.add(
					new BigInteger(Integer.toString(i))
					.multiply(
					new BigInteger(Integer.toString(a)).pow(i)));
		}
		return sum;
	}

}
